const fp = require('lodash/fp')
const {
  Maybe,
  Container
} = require('./support')
// let maybe = Maybe.of([5, 6, 1])

// let ex1 = fp.flowRight(fp.map(v => fp.add(v, 1)))
// console.log(maybe.map(ex1))

// // let ex1 = (x) => maybe.map(arr => fp.map(v => fp.add(v, x), arr))
// // console.log(ex1(3))

// let xs = Container.of(['do', 'ray', 'me', 'fa', 'so', 'la', 'xi', 'do'])
// let ex2 = () => {
//   // 你需要实现的函数
//   return xs.map(fp.first)._value
// }
// console.log(ex2())

let safeProp = fp.curry(function (x, o) {
  return Maybe.of(o[x])
})
let user = {
  id: 2,
  name: 'Albert'
}
let ex3 = () => {
  // 你需要实现的函数
  return safeProp('name', user).map(fp.first)._value
}
console.log(ex3())

// let ex4 = function (n) {
//   let tmp1 = new Maybe(n);
//   let tmp2 = tmp1.map(parseInt);
//   return tmp2._value;
// };
// console.log(ex4())
// console.log(ex4(2))